package com.sxz.sbs.module.telephone.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sxz.sbs.R;
import com.sxz.sbs.module.telephone.bean.TelBookBean;

import java.util.List;
/**
 * Created by hp on 2018/1/6.
 * 部门列表Adapter
 */

public class TelDepartmentAdapter extends BaseQuickAdapter<TelBookBean,BaseViewHolder> {

    private int selectIndex= 0;

    public TelDepartmentAdapter(@Nullable List<TelBookBean> data) {
        super(R.layout.item_teldepartment,data);
    }
    @Override
    protected void convert(BaseViewHolder holder, TelBookBean item) {

        holder.setText(R.id.tv_departmentname,item.getTxt_DepartmentName());
        if (selectIndex == holder.getAdapterPosition()) {
            holder.setTextColor(R.id.tv_departmentname,mContext.getResources().getColor(R.color.color_main));
            holder.setVisible(R.id.line_departmentname,true);
        } else {
            holder.setTextColor(R.id.tv_departmentname,mContext.getResources().getColor(R.color.color_text_3));
            holder.setVisible(R.id.line_departmentname,false);
        }
    }

    /**
     * 设置按压下标
     * @param position
     */
    public void setPressIndex(int position) {
        this.selectIndex = position;
        notifyDataSetChanged();
    }
}
